import {common, userInfo} from './url'
import { axios } from '../utils/request';
import qs from 'qs';

/**
 * user func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login(parameter) {
  return axios({
    url: common.login,
    method: 'post',
    data: qs.stringify(parameter)
  })
}

export function queryUserPermission() {
  return axios({
    url: userInfo.getPermission,
    method: 'get'
  })
}

export function init(parameter) {
  return axios({
      url: common.init,
      method: 'post',
      data: parameter
    }
  )
}


export function logout(logoutToken) {
  return axios({
    url: common.logout,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'X-Access-Token':  logoutToken
    }
  })
}